<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
    <title>编辑个人信息</title>
</head>
<style>
    .layui-form-item{
        margin-bottom: 8px;
    }
</style>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div id="cardBodyDiv" class="layui-card-body" style="padding: 15px;">
            <form class="layui-form layui-form-pane" action="" lay-filter="component-form-group">
                <input type="hidden" name="id" th:value="${entity.id}"/>
                <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" lay-verify="title" th:value="${entity.name}"  maxlength="30" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">电话</label>
                    <div class="layui-input-block">
                        <input type="text" name="phone" lay-verify="title" th:value="${entity.phone}"  maxlength="30" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item" style="margin-top: 20px">
                    <label class="layui-form-label">头像</label>
                    <button type="button" class="layui-btn" id="mobileTest1" style="margin-top: -12px">
                        <i class="layui-icon">&#xe67c;</i>上传头像
                    </button>
                    <img  id="mobileCoverImg" class="originalImg" th:src="${entity.header}"  style="height: 50px;min-width: 50px;"/>
                </div>
                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;">
                            <a class="layui-btn" lay-submit="" lay-filter="component-form-demo1">保存</a>
                            <a class="layui-btn" onclick="auth()">申请认证</a>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</div>
<script src="/layuiadmin/layui/layui.js"></script>
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/base.js"></script>
<script>
    selected();

    function auth(){
        layer.prompt({title: '请输入您的认证介绍以及证明，如已认证过重新申请认证则默认放弃当前认证身份', formType: 2}, function(text, index){
            basePost({
                url:"/mobileCustomer/myUpdateData.do",
                data:{
                    authStatus:1,
                    authMark:text,
                    type:1,
                },
                success:function (obj) {
                    layer.closeAll();
                    layer.confirm('申请完成！', {
                        title: '提示',
                        btn: ['确定'], //按钮
                        skin: 'layui-layer-molv',
                        closeBtn: 0
                    }, function(){
                        window.location.reload();
                    });
                }
            })
        });
    }

    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'laydate','upload'], function(){
        var $ = layui.$
            ,admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,form = layui.form;
        form.render(null, 'component-form-group');
        laydate.render({
            elem: '#LAY-component-form-group-date'
        });
        uploadOneImg('#mobileTest1', 'information', function (res) {
            if (res.code == 200) {
                //上传完毕回调
                $("#mobileCover").val(res.data);
                $("#mobileCoverImg").attr("src", res.data);
            } else {
                layer.alert(res.msg, {icon: 2, skin: 'layui-layer-molv'})
            }
        }, 670, 460);

        /* 监听提交 */
        form.on('submit(component-form-demo1)', function(data){
            var da = data.field;
            da.header = $("#mobileCoverImg").attr("src");
            basePost({
                url:"/mobileCustomer/myUpdateData.do",
                data:da,
                success:function (req) {
                    window.location.reload();
                }
            })
            return false;
        });
    });

</script>

</body>

</html>
